home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 March / CMCD0305.ISO / Software / Shareware / Utilitare / emu / Emu8086_Setup_307c.exe / {app} / Samples / int21.asm < prev    next >
Assembly Source File  |  2002-11-28  |  1KB  |  61 lines

  1. ; This sample gets a string
  2. ; from a user, and prints
  3. ; it out.
  4. ; INT 21h is used, thus
  5. ; DOS operating system is
  6. ; required.
  7.  
  8. #make_COM#
  9.  
  10. ; COM file is loaded at 100h
  11. ; prefix:
  12.         ORG  100H  
  13.  
  14. ; set data segment:
  15.         MOV AX, CS
  16.         MOV DS, AX
  17.         MOV ES, AX
  18.  
  19. ; input a string:
  20.         MOV DX, OFFSET s1
  21.         MOV AH, 0AH
  22.         INT 21h
  23.  
  24. ; get one line down,
  25. ; by printing new
  26. ; line characters:
  27.         MOV DX, offset nl
  28.         MOV AH, 9
  29.         INT 21h
  30.  
  31. ; set '$' to the end of
  32. ; inputed string:
  33.         MOV DI, offset s1
  34.         XOR BX, BX
  35. ; second byte of buffer holds
  36. ; the number of inputed
  37. ; characters:
  38.         MOV BL, [DI+1]
  39.         MOV BYTE PTR [DI+BX+2], '$'
  40.  
  41. ; print the entered string:
  42.         MOV DX, offset s1
  43. ; first byte is buffer size,
  44. ; second actual characters
  45. ; entered, we skip
  46. ; these 2 bytes:
  47.         ADD DX, 2
  48.         MOV AH, 9
  49.         INT 21h
  50.  
  51. ; exit to operating
  52. ; system:
  53.         MOV AH, 4Ch
  54.         INT 21h
  55.  
  56. ; data:
  57. s1 DB 30, 30 dup(' ')
  58. nl DB 13, 10, '$'
  59.  
  60. END
  61.